#include "Menu.h"

void Menu_class::MenuRun(Sprite* s, Input* In, HWND& hWnd, HINSTANCE& hInst, bool bWindowed)
{
	sprite = s;
	menuInput = In;
	menuInput->init(hWnd, hInst);
	//initial state
	menuState = Main;
	//initialize buttons from Will Zepeda code
	for(int i = 0; i < mainButtons; i++)
	{
		button[i].loadTexture("button.png");
		if(i < mainButtons-2)
		{
			button[i].setPos(800/4,(i*100)+200);
			button[i].setButtonType(i);
		}
		else
		{
			button[i].setPos(800/4,600/3);
			button[i].setButtonType(Back);
		}

	}//end of button init

	//draws the background to the main menu
	for(int i = 0; i < mainButtons; ++i)
	{
		menuSprite[i].loadTexture("deck-of-cards.png");
		menuSprite[i].setScale(1.6f, 1.2f);
	}
	c_directxF.Init(hWnd, hInst, bWindowed);
}

//void Menu_class::Update(int a_ms)
//{
//	menuInput->Update();
//	switch(menuState)
//	{
//	case Main:
//		/*Overall Main menu execution*/
//		/*keyboard executiables*/
//		if(menuInput->KeyPressed(DIK_M))
//		{
//			//main
//			menuState = Main;
//		}
//		if(menuInput->KeyPressed(DIK_S))
//		{
//			//start game
//			menuState = Start;
//		}
//		if(menuInput->KeyPressed(DIK_O))
//		{
//			//options
//			menuState = Option;
//		}
//		if(menuInput->KeyPressed(DIK_Q))
//		{
//			//quit
//			menuState = mQuit;
//		}
//		
//			//Mouse input for the different menu states
//			for(int i = 0; i < mainButtons; i++)
//			{
//				//If the mouse is over the current button
//				if(button[i].inButton(menuInput->getMousePosition()))
//				{
//					//If so check what the type of that button is in order to switch to the approproproiate menu state
//					if(menuInput->leftClicked())
//					{
//						switch(button[i].getButtonType())
//						{
//						case Start:
//							{menuState = Start;break;}
//						case Option:
//							{menuState = Option;break;}
//						case mQuit:
//							{menuState = mQuit;break;}
//						}
//					}
//				}
//			}
//		break;
//	case Start:
//		/*Starts the game*/
//		/*take render and update from WinMain put here and have WinMain call this case*/
//		if(c_directxF.Done()){
//			menuState = Main;
//		}
//		c_directxF.Update(a_ms);
//		c_directxF.Render();
//		break;
//	case Option:
//		/*Goes to options*/
//		optionState = OptionType;
//		break;
//	case mQuit:
//		/*closes the game*/
//		PostQuitMessage(0);
//		break;
//	};
//
//	switch(OptionType)
//	{
//		printf("In Options,\n press C for controls, press R for rules, press T for credit, press B to return");
//		if(menuInput->KeyPressed(DIK_C)){OptionType = Controls;}
//		if(menuInput->KeyPressed(DIK_R)){OptionType = Rules;}
//		if(menuInput->KeyPressed(DIK_T)){OptionType = Credit;}
//		if(menuInput->KeyPressed(DIK_B)){menuState = Main;}
//	case Controls:
//		/*view the controls in a text*/
//		/*keys "12345" select cards to put up for discard;
//		Enter key finalizes decisions made to compare hands;
//		Escape key ends the game immediately;*/
//		printf("keys 12345 select cards, Enter Key ends turn, Esc Closes game");
//		if(menuInput->KeyPressed(DIK_B))
//		{
//			menuState = Main;
//		}
//		break;
//	case Rules:
//		/*view the rules in a text*/
//		printf("under construction");
//		if(menuInput->KeyPressed(DIK_B))
//		{
//			menuState = Main;
//		}
//		break;
//	case Adjust_Vol:
//		/*in some way adjust volume*/
//		/*won't have time to figure this out to manually adjust volume*/
//		break;
//	case Credit:
//		/*view credits in text*/
//		/*should have it display for 5-10 seconds down to 0 and then return to Main menu*/
//		printf("Technical Lead: Jordan Vaughn, General Lead: David DJ Jackson, Supporter: Micheal Carpenter");
//		if(menuInput->KeyPressed(DIK_B))
//		{
//			menuState = Main;
//		}
//		break;
//	case Back:
//		/*return to the main menu screen*/
//		if(menuInput->KeyPressed(DIK_B))
//		{
//			menuState = Main;
//		}
//		break;
//	};
//	//return Main;
//}

/*New switch statement for menu*/
//void Menu_class::Update(int a_ms)
//{
//	switch(menuState)
//	{
//	case Main:
//		/*Overall Main menu execution*/
//		/*keyboard executiables*/
//		if(menuInput->KeyPressed(DIK_M)){/*main*/menuState = Main;}
//		if(menuInput->KeyPressed(DIK_S)){/*start game*/menuState = Start;}
//		if(menuInput->KeyPressed(DIK_O)){/*options*/menuState = Option;}
//		if(menuInput->KeyPressed(DIK_Q)){/*quit*/menuState = mQuit;}
//
//		for(int i = 0; i < mainButtons; ++i)
//		{
//			menuSprite[i].loadTexture("deck-of-cards.png");
//			menuSprite[i].setScale(1.6f, 1.2f);
//		}
//		break;
//	case Start:
//		switch(step){
//		};
//
//		if(c_directxF.Done()){
//			menuState = Main;
//		}
//		c_directxF.Update(a_ms);
//		c_directxF.Render();
//		break;
//	case Option:
//		printf("In Options,\n press C for controls, press R for rules, press T for credit, press B to return");
//		if(menuInput->KeyPressed(DIK_C)){OptionType = Controls;}
//		if(menuInput->KeyPressed(DIK_R)){OptionType = Rules;}
//		if(menuInput->KeyPressed(DIK_T)){OptionType = Credit;}
//		if(menuInput->KeyPressed(DIK_B)){menuState = Main;}
//		optionState = OptionType;
//		switch(OptionType){
//			case Controls:
//				printf("keys 12345 select cards, Enter Key ends turn, Esc Closes game");
//				if(menuInput->KeyPressed(DIK_B)){menuState = Main;}
//				break;
//			case Rules:
//				printf("under construction");
//				if(menuInput->KeyPressed(DIK_B)){menuState = Main;}
//				break;
//			case Adjust_Vol:
//				break;
//			case Credit:
//				printf("Technical Lead: Jordan Vaughn, General Lead: David DJ Jackson, Supporter: Micheal Carpenter");
//				if(menuInput->KeyPressed(DIK_B)){menuState = Main;}
//				break;
//		};
//		break;
//	case mQuit:
//		/*closes the game*/
//		PostQuitMessage(0);
//		break;
//	};
//}
//
//void Menu_class::release()
//{
//	c_directxF.Shutdown();
//}